
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="weddingPhotography/css/bootstrap.min.css" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="weddingPhotography/css/commonly-used-show.css" />
    <script type="text/javascript" src="weddingPhotography/js/jquery.min.js" ></script>
    <script type="text/javascript" src="weddingPhotography/js/bootstrap.js" ></script>

     <title>首页</title>

    <style>
        .mydiv{
            text-align: center;
            margin-left: 10px;
            margin-top: 10px;
            float: left
        }
    </style>

</head>

<body class="mybody">

<jsp:include page="theTopMenuUser.jsp" />


<div class="container-fluid">
    <div class="row">
        <div class="col-md-2">
            <div class="text-center" id="left-content">
                <div class="list-group">
                    <a href="${pageContext.request.contextPath}/user" class="list-group-item active">首页</a>
                </div>
                <div class="list-group">
                    <a href="${pageContext.request.contextPath}/myFolder" class="list-group-item">我的文件夹</a>
                    <a href="${pageContext.request.contextPath}/myPictureFile" class="list-group-item">我的相册</a>
                    <a href="${pageContext.request.contextPath}/addPicture" class="list-group-item">上传照片</a>
                    <a href="${pageContext.request.contextPath}/regulatorMyPictureFile" class="list-group-item">管理相册</a>
                    <a href="${pageContext.request.contextPath}/latestNews" class="list-group-item">最新资讯</a>
                    <a href="${pageContext.request.contextPath}/worksAppreciation" class="list-group-item">作品欣赏</a>
                </div>
                <div class="list-group">
                    <a href="${pageContext.request.contextPath}/assistance" class="list-group-item">留言与联系</a>
                </div>
            </div>
        </div>



        <div class="col-md-10">
            <div class="page-header">
                <h1 style="font-size: 18px">我的图片</h1>
            </div>

            <div class="row" id="my_file">

            </div>

        </div>


    </div>

</div>

<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }

    window.onload = function(){
        photoInfo();
    }

    function photoInfo(){
        var postUrl = "${pageContext.request.contextPath}/member/selectMenusIdAll";
        var str = {
            "userId": userdt.result.id
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    $("#my_file").append("<div class=\"mydiv\"><a href='${pageContext.request.contextPath}/addMenus'><img src='" + "weddingPhotography/img/add_picture.png" + "' width=\"100px\" height=\"100px\" ></a>" +
                        "<br><p>" + "去添加" + "</p></div>");
                }else {
                    imgShow(data);
                }
            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }

    function imgShow(list){
        var j = 0;
        for(var i = 0; i < list.result.length; i++){

            j++;
            $("#my_file").append("<div class=\"mydiv\"><a href='${pageContext.request.contextPath}/photoAlbums?menu=" + list.result[i].moduleName + "'><img src='" + "weddingPhotography/img/img_folder.png" + "' width=\"150px\" height=\"150px\" ></a>" +
                "<br><p>" + list.result[i].moduleName + "</p></div>");
            if(j === 5){
                j = 0;
            }

        }
    }

</script>
</body>
</html>
</span>